home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / surfmodl / surfm203.arc / SURFSRC.ARC / INTRFILL.INC < prev    next >
Text File  |  1987-01-05  |  3KB  |  77 lines

  1. procedure INTRFILL (Surf, Color: integer; Shades: nodearray);
  2.  
  3. { Interpolated fillsurf routine for Gouraud shading }
  4.  
  5. var Npts: integer;               { #points on edges of the surface }
  6.     Nextpt: integer;             { Next point to use for filling }
  7.     Node1, Node2: integer;       { node numbers of endpts of line }
  8.     Xpt, Ypt: points;            { pts on edges of surface }
  9.     Shpt: realpts;               { shade at each point }
  10.     Vert: integer;               { vertex number }
  11.     Shade1, Shade2: real;        { Shades at endpoint nodes }
  12.  
  13. begin
  14. {$ifdef BIGMEM}
  15. with ptrd^ do with ptre^ do with ptrh^ do
  16. with ptri^ do
  17. begin
  18. {$endif}
  19.  
  20.   if (onscreen (Surf)) then begin
  21.  
  22.     Npts := 0;
  23.     for Vert := 1 to Nvert[Surf]-1 do begin
  24.       Node1 := Konnec (Surf, Vert);
  25.       Node2 := Konnec (Surf, Vert+1);
  26.       Shade1 := Shades[Node1];
  27.       Shade2 := Shades[Node2];
  28.       if (Shade1 < Ambient[Matl[Surf]]) then
  29.         Shade1 := Ambient[Matl[Surf]];
  30.       if (Shade2 < Ambient[Matl[Surf]]) then
  31.         Shade2 := Ambient[Matl[Surf]];
  32.       storshades (round(Xtran[Node1]), round(Ytran[Node1]),
  33.                   round(Xtran[Node2]), round(Ytran[Node2]),
  34.                   Shade1, Shade2, Xpt, Ypt, Shpt, Npts);
  35.       if (Npts < 0) then
  36.         badsurf;
  37.     end; { for Vert }
  38.  
  39. { One last line to close the polygon }
  40.     Node1 := Konnec (Surf, Nvert[Surf]);                { last node }
  41.     Node2 := Konnec (Surf, 1);                          { first node }
  42.     Shade1 := Shades[Node1];
  43.     Shade2 := Shades[Node2];
  44.     if (Shade1 < Ambient[Matl[Surf]]) then
  45.       Shade1 := Ambient[Matl[Surf]];
  46.     if (Shade2 < Ambient[Matl[Surf]]) then
  47.       Shade2 := Ambient[Matl[Surf]];
  48.     storshades (round(Xtran[Node1]), round(Ytran[Node1]),
  49.                 round(Xtran[Node2]), round(Ytran[Node2]),
  50.                 Shade1, Shade2, Xpt, Ypt, Shpt, Npts);
  51.     if (Npts < 0) then
  52.       badsurf;
  53.  
  54. { Sort the line segment points, first by Y, then by X }
  55.     shellshades (Xpt, Ypt, Shpt, Npts);
  56.  
  57. { Now draw the filled surface }
  58.     Nextpt := 1;
  59.     while (Nextpt < Npts) do begin
  60.       if (abs(Xpt[Nextpt] - Xpt[Nextpt+1]) > 1) and
  61.           (Ypt[Nextpt] = Ypt[Nextpt+1]) then begin
  62.         intrdraw (Xpt[Nextpt], Xpt[Nextpt+1], Ypt[Nextpt], Color,
  63.                   Shpt[Nextpt], Shpt[Nextpt+1]);
  64.         Nextpt := Nextpt + 2;
  65.       end else begin
  66.         intrplot (Xpt[Nextpt], Ypt[Nextpt], Color, Shpt[Nextpt]);
  67.         Nextpt := Nextpt + 1;
  68.       end;
  69.     end; { while }
  70.     if (Nextpt = Npts) then
  71.       intrplot (Xpt[Nextpt], Ypt[Nextpt], Color, Shpt[Nextpt]);
  72.   end; { if onscreen }
  73. {$ifdef BIGMEM}
  74. end; {with}
  75. {$endif}
  76. end; { procedure INTRFILL }
  77.